package game.players.states;

import com.uqbar.vainilla.DeltaState;

import game.ball.SoccerBall;
import game.players.SoccerPlayer;

public abstract class WithoutBall extends PlayerState {

	public WithoutBall(SoccerPlayer player) {
		super(player);
	}
	
	@Override
	public boolean isWithBall() {
		return false;
	}
	
	@Override
	public void update(DeltaState deltaState) {
		SoccerBall ball = this.getPlayer().getScene().getSoccerBall();
		
		if (ball.isFree() && this.collidesAgainstBall(ball, this.getPlayer()))
			this.takePossession(ball);
	}
	
	public abstract void takePossession(SoccerBall ball);

	public abstract boolean collidesAgainstBall(SoccerBall ball, SoccerPlayer player);

}
